package com.alisls.demo.springcloud.stream.rabbit.producer;

import com.alisls.demo.springcloud.stream.rabbit.channel.MyProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 描述信息
 *
 * @author Ke Wang
 * @date 2020/10/15
 */
@Component
@EnableBinding(MyProcessor.class)
public class MessageSender {

    @Autowired
    @Qualifier(value = "myOutput")
    private MessageChannel myOutput;

    /**
     * 发送消息
     * @param message
     */
    public void sendMessage(Object message) {
        myOutput.send(MessageBuilder.withPayload(message).build());
    }

}
